
<template>
  <page-list :url="url" :params="filter" @initList="_initList">
    <!-- <div class="info-list mb-10" v-for="(item, index) in list" :key="index"> -->
        <eagle-cell style="margin-top: 10px; border-radius: 8px" v-for="(item, index) in list" :key="index" class="card">
          <van-tag
            v-if="item.IsRead === true"
            class="info_tag"
            color="#008000"
            >已读</van-tag>
          <van-tag v-if="item.IsRead != true" class="info_tag" type="warning"
            >未读</van-tag
          >
          <div @click="goDetail(item)">
            <div class="warn_header">
              <div>{{ index + 1 }}、{{ item.Title }}</div>
            </div>
            <div class="plan-detail-describe">
              <div>{{ item.Content }}</div>
            </div>
    
            <div style="margin-top: 10px;" class="plan-detail-describe mt-5">
              接收时间： {{ item.CreateDate }}
            </div>


          </div>
        </eagle-cell>
      <!-- 弹出层 -->
    <!-- </div> -->
  </page-list>
</template>

<script>

// import { doMessageClick } from "@/utils/message.js";
import PageList from "@/components/PageList/PageList.vue";
export default {

  components: {   PageList },
  data() {
    return {
      loading: false,
      finished: false,
      url: "/CommonMessage/GetPageData",
      filter: { dataType: "MessageList" },
      list: [],

    };
  },
  created() {

  },
  methods: {
    _initList(list) {
      this.list = list;
    },

    goDetail(item) {
      let _this = this;
      if(!item.IsRead){
        let params = { id: item.ID };
        console.log(item)
        console.log(params)
      _this.$axios
      .get("/CommonMessage/ReadMessage/",{params:params})
      .then((res) => {
        item.IsRead=true
      })
      }

      let type=item.TemplateCode
      let RecordID=item.RecordID
      if(item.MobileUrl){
        this.$router.push({
        path: "item.MobileUrl",
        query: { code: item.Code },
      });
      }else if(type=="DangerPlanTask"){
        this.$router.push({
        path: "/Danger/DangerCheckTaskEdit",
        query: { id: RecordID },
      });
      }else if(type=="CommonInfo"){
        this.$router.push("/CommonInfo/InfoDetail?id=" + RecordID);
      }else if(type=="JGDangerCorrective"){
        this.$router.push({
        path: "/Danger/JGWindowCorrectiveDetail",
        query: { id: RecordID},
      });
      }else {
        this.doMessageClick(item)
      }



      
      // if(type)
      // this.$router.push({
      //   path: "/SiteFireEquipmentDetail",
      //   query: { code: item.Code },
      // });
    },
    doMessageClick(item) {
    if (item.TemplateCode == "DangerAssign") {
        this.$router.push({
            path: "/Danger/DangerCheckDetailAssignDetail",
            query: { id: item.RecordID },
        });
    } else if (item.TemplateCode == "DangerFormulate") {
        this.$router.push({
            path: "/Danger/MyMeasuresToDetail",
            query: { id: item.RecordID },
        });
    } else if (item.TemplateCode == "DangerCorrective") {
        this.$router.push({
            path: "/Danger/MyCorrectivedDetail",
            query: { id: item.RecordID },
        });
    } else if (item.TemplateCode == "DangerVerify") {
        this.$router.push({
            path: "/Danger/DangerCheckTaskDetailVerifyDetail",
            query: { id: item.RecordID },
        });
    } else if (item.TemplateCode == "DangerPlanTask") {
        this.$router.push({
            path: "/Danger/DangerCheckTaskEdit",
            query: { id: item.RecordID },
        });
    } else if (item.TemplateCode == "DangerHiddenDanger") {
        this.$router.push({
            path: "/Danger/DangerCheckTaskDetailEdit",
            query: { id: item.RecordID },
        });
    } else if (item.TemplateCode == "DangerHiddenDangerBack") {
        this.$router.push({
            path: "/Danger/DangerCheckTaskDetailEdit",
            query: { id: item.RecordID },
        });
    } else if (item.TemplateCode == "ExamAlloc") {
        this.$router.push({
            path: "/Train/ExExamExplain",
            query: { id: item.RecordID },
        });
    } else if (item.TemplateCode == "TrainPlanAlloc") {
        this.$router.push({
            path: "/Train/TrainingplanDetail",
            query: { id: item.RecordID },
        });
    } else if (item.TemplateCode == "WHMeasuresForAcceptance") { //措施验收
        this.$router.push({
            path: "/whInvestigationReportLogRMBrowseDetail",
            query: { id: item.RecordID, state: "ForAcceptance" },
        });
    } else if (item.TemplateCode == "WHMeasuresToRectify" || item.TemplateCode == "WHMeasuresForAcceptanceBack") { //措施退回验收&& 措施整改
        this.$router.push({
            path: "/whInvestigationReportLogRMBrowseDetail",
            query: { id: item.RecordID, state: "RectificationMeasures" },
        });
    } else if (item.TemplateCode == "WHInvestigationReportAssistance" || item.TemplateCode == "WHAccidentInvestigationReport") { //调查报告协助 && 调查组长指派
        this.$router.push({
            path: "/whInvestigationReportAccidentInvestigate",
            query: {},
        });
    } else if (item.TemplateCode == "WHAccidentInitialReport") { //	初始报告提交指派
        this.$router.push({
            path: "/whAccidentInitialReportToBeAssignedList",
            query: {},
        });
    } else {
        if (item.MobileUrl) {
            let url = item.MobileUrl;
            if (url.includes("/h5/#/")) {
                url = url.substring(6);
            }
            this.$router.push({
                path: url,
            });
        } else {
            console.log(item.TemplateCode + "|" + item.Controller);
            Toast.fail("暂未支持导航，请在电脑端查看")
        }
    }
},
    onLoad() {
      console.log("onLoad")
      this.loading = true;
      ++this.filter.page;
      list(this.filter).then((res) => {
        this.loading = false;
        this.filter.page = res.data.PageIndex;
        this.list = this.list.concat(res.data.Data);
        if (!res.data.HasNextPage) {
          this.finished = true;
        }
      });
    },

  },
};
</script>

<style lang="less" scoped>
.eagle-cell {
  padding: 0px 0px;

  .info_tag {
    position: absolute;
    border-top-right-radius: 3px;
    border-bottom-left-radius: 3px;
    top: 0;
    right: 0;
  }
}

.warn_item {
  
  margin: 10px;
  border-radius: 5px;
  position: relative;
}

.warn_header {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 10px;

  .warn_tag {
    position: absolute;
    right: 0;
    top: 0;
    border-radius: 26.64rem 0 0 26.64rem;
  }
}

.dep_sort {
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}

.card_check {
  border-radius: 8px;
}

.dep_btm {
  display: flex;
  justify-content: flex-end;
  width: 30%;
  float: right;

  .btm_item {
    display: flex;
    align-items: center;

    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}

.plan-detail-describe {
  width: 90%;
  font-size: 12px;
  line-height: 1.2;
  // word-break: break-all;
  text-overflow: ellipsis;
  color: #666;
  display: -webkit-box;
  /** 对象作为伸缩盒子模型显示 **/
  -webkit-box-orient: vertical;
  /** 设置或检索伸缩盒对象的子元素的排列方式 **/
  -webkit-line-clamp: 2;
  /** 显示的行数 **/
  overflow: hidden;
  /** 隐藏超出的内容 **/
  word-break: break-all;
}</style>
